package com.saudidentalapp;


import android.content.Intent;
import android.os.Bundle;
import android.view.LayoutInflater;
import android.view.View;
import android.widget.ImageView;
import android.widget.TabHost;
import android.widget.TextView;

public class TabActivity extends android.app.TabActivity
{
	static TabHost tabHost;
	/** Called when the activity is first created. */
	public void onCreate(Bundle savedInstanceState) 
	{
		super.onCreate(savedInstanceState);
		setContentView(R.layout.activity_main);
		setTabs() ;		
		switchTab(0);
	}
	
	private void setTabs()
	{
		addTab("    Home     ", R.drawable.icn_home, DashBoardActivity.class);		
		addTab("   Welcome   ", R.drawable.icn_welcome, AboutDsActivity.class);		
		addTab("  About KSA  ", R.drawable.icn_about_saudi, AroundTown.class);		
		addTab("  Speakers   ", R.drawable.icn_speakers, SpeakerActivity.class);		
		addTab(" Exhibition  ", R.drawable.icn_exhibition, ExhibitionActivity.class);		
		addTab("   Awards    ", R.drawable.icn_award, AwardsActivity.class);
		addTab("Org.Committee", R.drawable.icn_comitee, OrganizingCommittee.class);		
		addTab("   Program   ", R.drawable.icn_sci_program, ProgramActivity.class);		
		addTab("   Gallery   ", R.drawable.icn_gallery, GalleryActivity.class);		
		addTab("   Facebook  ", R.drawable.icn_facebook, FacebookActivity.class);
		addTab("   Twitter   ", R.drawable.icn_twitter, TwitterActivity.class);
		addTab("  Contact Us ", R.drawable.icn_contact_us, ContactDentalSociety.class);
		
		//removed
		//addTab(" Search ", R.drawable.search_normal, SearchActivity.class); 
		
	}
	
	private void addTab(String labelId, int drawableId, Class<?> c)
	{
		tabHost = getTabHost();
		//tabHost.setBackgroundResource(R.drawable.bg_tab_menu);
		Intent intent = new Intent(this, c);
		TabHost.TabSpec spec = tabHost.newTabSpec("tab" + labelId);	
		
		
		View tabIndicator = LayoutInflater.from(this).inflate(R.layout.tab_indicator, getTabWidget(), false);
		TextView title = (TextView) tabIndicator.findViewById(R.id.title);
		title.setText(labelId);
		ImageView icon = (ImageView) tabIndicator.findViewById(R.id.icon);
		icon.setImageResource(drawableId);
		
		spec.setIndicator(tabIndicator);
		spec.setContent(intent);
		tabHost.addTab(spec);
	}
	
	/**
	 * Method to set or switch the tab.
	 * @param tab - int index of the tab
	 */
	public void switchTab(int tab)
	{
        tabHost.setCurrentTab(tab);
	}
}